        subroutine damping(damp,NORB,P,P_old)
!******************************************************************************
! Formular:
!    P=damp*P+(1-damp)*P
!******************************************************************************
        implicit none
        !----dummy variables
        !--------------------------------------------------------
        real*8, intent(in) :: damp
        integer :: NORB
        real*8 :: P(NORB,NORB),P_old(NORB,NORB)

        !P=damp*P+(1-damp)*P_old
        ! damp ~ 0 is small damping and damp ~ 1 is large damping. Changed to
        ! below
        P=(1.d0-damp)*P+damp*P_old

        return
        end subroutine damping

